﻿#include "pch.h"

CConcCaculator::CConcCaculator()
{
    memset(this, 0, sizeof(CConcCaculator));
}

void CConcCaculator::printSelf(char *captionUpper, int32_t deep)
{
    char caption[1024];
    sprintf(caption, "%s:%s", captionUpper, "CConcCaculator");
    print4x(this, sizeof(CConcCaculator), caption);
    if (--deep >= 0)
    {
        if (this->pEParaWrapper)
        {
            this->pEParaWrapper->printSelf(caption, deep);
        }
        if (this->pGrpInfWrapper)
        {
            this->pGrpInfWrapper->printSelf(caption, deep);
        }
        if (this->pResInfWrapper)
        {
            this->pResInfWrapper->printSelf(caption, deep);
        }
        if (this->pIdtInfWrapper)
        {
            this->pIdtInfWrapper->printSelf(caption, deep);
        }
        if (this->pStdInfManager)
        {
            this->pStdInfManager->printSelf(caption, deep);
        }
    }
}

// sub_1000B395
CConcCaculator *CConcCaculator::init(CResInfWrapper *pResInf, CEParaWrapper *pEPara, CGrpInfWrapper *pGrpInf,
                                     CIdtInfWrapper *pIdtInf, CStdInfManager *pStdInf)
{
    this->pEParaWrapper = pEPara;
    this->pGrpInfWrapper = pGrpInf;
    this->pResInfWrapper = pResInf;
    this->pIdtInfWrapper = pIdtInf;
    this->pStdInfManager = pStdInf;
    memset((void *)&this->tukpkFactor, 0, sizeof(TUkPkFactor));
    this->yMinUnit = 1.0;
    return this;
}

// sub_1000B3F5
int32_t CConcCaculator::clean()
{
    int32_t result;

    result = this->pEParaWrapper->getLen();
    if (result)
    {
        result = this->pGrpInfWrapper->clean();
    }
    return result;
}

// sub_1000B419
int32_t CConcCaculator::setMetric(TDLLMETRIC *metric, char flag)
{
    TDLLResultListItem *pDLLResult = (TDLLResultListItem *)this->pResInfWrapper->getHead();
    int32_t num;

    this->pResInfWrapper->cleanIdnoNameEtc();
    this->pResInfWrapper->calcAreaPer();
    checkMetric(metric);
    this->setIdtInf(1);
    if (this->pStdInfManager)
    {
        this->initStdInf();
    }
    else
    {
        this->setResInfoConc(metric, flag);
        if (this->pEParaWrapper->getLen())
        {
            num = this->pResInfWrapper->getNum();
            pDLLResult = (TDLLResultListItem *)this->pResInfWrapper->getHead();
            this->pGrpInfWrapper->calcGroupAggregate(pDLLResult, num);
        }
    }
    return true;
}

// sub_1000BEF2
char CConcCaculator::setIdtInf(char flag)
{
    double rtime;
    double band;
    int32_t based;
    int32_t resultIdx;
    int32_t validIdx;
    double idtTime;
    int32_t vCount;

    if (this->pIdtInfWrapper->qualitMode == 2)
    {
        return this->setIdtInfExMode2();
    }
    vCount = this->pIdtInfWrapper->setTypeExInf();
    if (vCount > 0)
    {
        //        idtTime = 0.0;
        band = 0.0;
        validIdx = 0;
        //        resultIdx = 0;
        based = -1;
        while (validIdx < vCount)
        {
            resultIdx = this->pIdtInfWrapper->getValidNo(validIdx);
            idtTime = this->pIdtInfWrapper->getIdtTimeAndBaseBand(resultIdx - 1, &based, &band);
            rtime = this->pResInfWrapper->getInBandOutRTime(idtTime, band, based, 9.0);
            this->pIdtInfWrapper->setTypeExRTime(validIdx++, rtime);
        }
    }
    this->pIdtInfWrapper->clearIndexes();
    char result = this->setIdtInfExModeN2(flag);
    return result;
}

// sub_1000C00F
int32_t CConcCaculator::setIdtInfExMode2()
{
    char *idtName;
    int32_t num;
    int32_t i;
    int32_t nextIdx;

    if (this->pIdtInfWrapper->qualitMode != 2)
    {
        return false;
    }
    num = this->pResInfWrapper->getNum();
    for (i = 0; i < num; ++i)
    {
        nextIdx = this->pIdtInfWrapper->getNextIndex(i);
        if (nextIdx > 0)
        {
            this->pResInfWrapper->setIdno(i, nextIdx);
            idtName = this->pIdtInfWrapper->getIdtName(nextIdx - 1);
            this->pResInfWrapper->setName(i, idtName);
        }
    }
    return true;
}

// sub_1000C0B0
int32_t CConcCaculator::setIdtInfExModeN2(char flag)
{
    int32_t num;
    int32_t i;
    char *idtName;
    int32_t idtNo;

    if (this->pIdtInfWrapper->qualitMode == 2)
    {
        return false;
    }
    num = this->pResInfWrapper->getNum();
    for (i = 0; i < num; ++i)
    {
        idtNo = this->setResInfoIdnoAndName(i, (double)(flag != 0 ? 9 : 0));
        if (idtNo > 0)
        {
            idtName = (char *)this->pIdtInfWrapper->getIdtName(idtNo - 1);
            if (i == 5)
            {
                println("idtNo=%d idtName=%s", idtNo, idtName);
            }
            this->pResInfWrapper->setIdnoAndName(i, idtNo, idtName);
            this->pIdtInfWrapper->setIdtnoIndex(idtNo - 1, i + 1);
        }
    }
    return true;
}

// sub_1000BCE6
CStdInfManager *CConcCaculator::initStdInf()
{
    int32_t i;
    int32_t j;
    int32_t idno;
    int32_t eMethod;
    double area;
    double height;
    double sumHeight;
    double sumArea;

    if (this->pStdInfManager->isAmtIndexNotZero())
    {
        this->pStdInfManager->cleanCPTItem();
    }
    sumArea = 0.0;
    sumHeight = 0.0;
    eMethod = this->pEParaWrapper->getEparamMethod();
    if (eMethod == 1)
    {
        for (i = 0; i < this->pResInfWrapper->getNum(); ++i)
        {
            if (this->pResInfWrapper->getIdno(i) > 0)
            {
                sumArea = pResInfWrapper->getArea(i) + sumArea;
                sumHeight = pResInfWrapper->getHeight(i) + sumHeight;
            }
        }
    }
    for (j = 0; j < this->pResInfWrapper->getNum(); ++j)
    {
        idno = this->pResInfWrapper->getIdno(j);
        if (idno > 0)
        {
            area = this->pResInfWrapper->getArea(j);
            height = this->pResInfWrapper->getHeight(j);
            if (eMethod == 1)
            {
                if (sumArea > 0.0)
                {
                    area = area / sumArea;
                }
                if (sumHeight > 0.0)
                {
                    height = height / sumHeight;
                }
            }
            this->pStdInfManager->addCptAreaAndWeight(idno - 1, area, (float)height);
            if (this->pStdInfManager->isValidAmpRepIndex())
            {
                this->pStdInfManager->eliminateRepNumInCPT(idno - 1);
            }
        }
    }
    if (this->pStdInfManager->reachedLastAmtRepsNum())
    {
        this->pStdInfManager->calcMethodValueAndWeightAll();
    }
    return this->pStdInfManager->incCurrentAmtIdx();
}

// sub_1000C187
int32_t CConcCaculator::setResInfoIdnoAndName(int32_t idx, double factor)
{
    int32_t based;
    double time;
    int32_t optimalIdx;
    int32_t idtPrevIndex;
    double dRight;
    double dLeft;
    int32_t i;
    double rTime;

    dLeft = 0.0;
    dRight = 0.0;
    rTime = this->pResInfWrapper->fetchResultRTime(idx, &dLeft, &dRight, factor);
    if (idx == 5)
    {
        println("rTime=%f dLeft=%f dRight=%f factor=%f   rrr=%d", rTime, dLeft, dRight, factor,
                this->pIdtInfWrapper->getNextIndexNearCenter(rTime, dLeft, dRight, 0));
    }
    for (i = this->pIdtInfWrapper->getNextIndexNearCenter(rTime, dLeft, dRight, 0); i > 0;
         i = this->pIdtInfWrapper->getNextIndexNearCenter(rTime, dLeft, dRight, i))
    {
        idtPrevIndex = this->pIdtInfWrapper->getIdtnoIndex(i - 1) - 1;
        if (idx == 5)
        {
            println("i=%d idtPrevIndex=%d judge=%d", i, idtPrevIndex,
                    this->pIdtInfWrapper->isBandExceedTime(i - 1));
        }
        if (idtPrevIndex < 0 || this->pIdtInfWrapper->isBandExceedTime(i - 1))
        {
            break;
        }
        based = 0;
        time = this->pIdtInfWrapper->getIdtTimeAndBaseBand(i - 1, &based, 0);
        optimalIdx = this->pResInfWrapper->getAOptimalIdx(time, based, idx, idtPrevIndex);
        if (optimalIdx == idx)
        {
            this->pResInfWrapper->setIdnoAndName(idtPrevIndex, 0, gResultItemName);
            if (idx == 5)
            {
                println("i=%d gResultItemName=%s", i, gResultItemName);
            }
            return i;
        }
    }
    if (idx == 5)
    {
        println("i=%d", i);
    }
    return i;
}

// sub_1000B4AE
void CConcCaculator::setResInfoConc(TDLLMETRIC *metric, int32_t flag)
{
    double amtMValue;
    int32_t basedOnArea;
    double m2m5Value;
    int32_t idno;
    int32_t idx;
    int32_t n;
    int32_t ii;
    int32_t jj;
    int32_t kk;
    int32_t ll;
    int32_t bandOut;
    double factor;
    int32_t num;
    int32_t i;
    int32_t j;
    int32_t k;
    int32_t l;
    int32_t m;
    double sumAreaOrHeight;
    double sumConc;
    int32_t eMethod;
    double conc;

    num = this->pResInfWrapper->getNum();
    sumAreaOrHeight = 0.0;
    eMethod = this->pEParaWrapper->getEparamMethod();
    amtMValue = calcAmtMValue((TSTDAMTListItem *)metric, eMethod);
    factor = amtMValue;
    if (amtMValue < 1.0e-30)
    {
        factor = 1.0;
    }
    switch (eMethod)
    {
    case 1:
        if (!flag)
        {
            for (i = 0; i < num; ++i)
            {
                amtMValue = this->calcAir(i, 0.0, 0.0);
                amtMValue = amtMValue + sumAreaOrHeight;
                sumAreaOrHeight = amtMValue;
            }
            //            amtMValue = sumAreaOrHeight;
            if (sumAreaOrHeight > 0.0)
            {
                for (j = 0; j < num; ++j)
                {
                    amtMValue = this->calcAir(j, 0.0, 0.0);
                    amtMValue = amtMValue * factor / sumAreaOrHeight;
                    this->pResInfWrapper->setConc(j, amtMValue);
                }
            }
        }
        break;
    case 2:
    case 5:
        this->setResInfoConcM2M5(metric);
        break;
    case 3:
    case 4:
    case 6:
        for (k = 0; k < num; ++k)
        {
            amtMValue = this->calcAir(k, 0.0, 0.0);
            amtMValue = amtMValue / factor;
            this->pResInfWrapper->setConc(k, amtMValue);
        }
        break;
    default:
        if (!flag)
        {
            for (l = 0; l < num; ++l)
            {
                basedOnArea = this->pEParaWrapper->isBasedOnArea();
                sumAreaOrHeight = this->pResInfWrapper->getAreaOrHeight(basedOnArea, l) + sumAreaOrHeight;
            }
            //            amtMValue = sumAreaOrHeight;
            if (sumAreaOrHeight >= 1.0)
            {
                for (m = 0; m < num; ++m)
                {
                    basedOnArea = this->pEParaWrapper->isBasedOnArea();
                    amtMValue = this->pResInfWrapper->getAreaOrHeight(basedOnArea, m) * 100.0 / sumAreaOrHeight;
                    this->pResInfWrapper->setConc(m, amtMValue);
                }
            }
        }
        break;
    }
    if (eMethod)
    {
        bandOut = false;
        if (eMethod == 2 || eMethod == 5)
        {
            amtMValue = pow10_istdK(metric);
            m2m5Value = amtMValue;
        }
        else
        {
            m2m5Value = 0.0;
        }
        for (n = 0; n < this->pIdtInfWrapper->getNum(); ++n)
        {
            if (this->pIdtInfWrapper->isBandExceedTime(n))
            {
                bandOut = true;
                this->setBandOutConc(n, factor, m2m5Value);
            }
        }
        if (bandOut && eMethod == 1 && !flag)
        {
            sumConc = 0.0;
            for (ii = 0; ii < num; ++ii)
            {
                idx = this->pResInfWrapper->getIdno(ii) - 1;
                if (idx >= 0 && this->pIdtInfWrapper->isBandExceedTime(idx))
                {
                    conc = this->pResInfWrapper->getConc(ii);
                }
                else
                {
                    amtMValue = this->calcAir(ii, 0.0, 0.0);
                    conc = amtMValue;
                    this->pResInfWrapper->setConc(ii, amtMValue);
                }
                //                amtMValue = sumConc + conc;
                sumConc = sumConc + conc;
            }
            if (sumConc >= 1.0)
            {
                for (jj = 0; jj < num; ++jj)
                {
                    conc = this->pResInfWrapper->getConc(jj);
                    double vv = conc * factor / sumConc;
                    this->pResInfWrapper->setConc(jj, vv);
                }
            }
        }
        if (!flag && !metric->byCalib && (eMethod == 5 || eMethod == 6))
        {
            sumConc = 0.0;
            for (kk = 0; kk < num; ++kk)
            {
                conc = 0.0;
                if (eMethod == 5)
                {
                    idno = this->pResInfWrapper->getIdno(kk);
                    if (!idno || !this->pIdtInfWrapper->checkStdNo(idno - 1))
                    {
                        conc = this->pResInfWrapper->getConc(kk);
                    }
                }
                else
                {
                    conc = this->pResInfWrapper->getConc(kk);
                }
                sumConc = sumConc + conc;
            }
            if (sumConc > 1.0)
            {
                for (ll = 0; ll < num; ++ll)
                {
                    idno = this->pResInfWrapper->getIdno(ll);
                    if (eMethod == 5)
                    {
                        if (!idno || !this->pIdtInfWrapper->checkStdNo(idno - 1))
                        {
                            conc = this->pResInfWrapper->getConc(ll);
                            this->pResInfWrapper->setConc(ll, conc * 100.0 / sumConc);
                        }
                    }
                    else
                    {
                        conc = this->pResInfWrapper->getConc(ll);
                        this->pResInfWrapper->setConc(ll, conc * 100.0 / sumConc);
                    }
                }
            }
        }
    }
}

// sub_1000C825
double CConcCaculator::calcAir(int32_t idx, double idtAreaOrHeight, double idtWeight)
{
    int32_t basedOnArea;
    double resAreaOrHeight;
    int32_t idno;

    idno = this->pResInfWrapper->getIdno(idx) - 1;
    basedOnArea = this->isIdtBaseOnArea(idx);
    resAreaOrHeight = this->pResInfWrapper->getAreaOrHeight(basedOnArea, idx);
    return this->calcIdtMethodVX(idno, resAreaOrHeight, idtAreaOrHeight, idtWeight);
}

// sub_1000C2E6
int32_t CConcCaculator::isIdtBaseOnArea(int32_t idx)
{
    int32_t idno;

    idno = this->pResInfWrapper->getIdno(idx) - 1;
    return this->pIdtInfWrapper->isBaseOnArea(idno, ((TEPara *)(this->pEParaWrapper->head))->based);
}

// sub_1000C544
double CConcCaculator::calcIdtMethodVX(int32_t idtNo, double resAreaOrHeight, double idtAreaOrHeight,
                                       double idtWeight)
{
    int32_t eMethod;
    double X;
    TDLLIDTListItem_1408Ex idt1408;
    double f0, f1, f2, f3;
    double eMethodVal;

    if (idtNo >= this->pIdtInfWrapper->getNum())
    {
        return 0.0;
    }
    if (resAreaOrHeight <= 0.0)
    {
        return 0.0;
    }
    if (this->yMinUnit < 1.0e-30)
    {
        this->yMinUnit = 1.0;
    }
    eMethod = this->pEParaWrapper->getEparamMethod();
    if (eMethod == 2 || eMethod == 5)
    {
        if (idtAreaOrHeight <= 0.0)
        {
            eMethodVal = 0.0;
        }
        else
        {
            eMethodVal = resAreaOrHeight / idtAreaOrHeight;
        }
    }
    else if (eMethod == 4)
    {
        eMethodVal = log(resAreaOrHeight / this->yMinUnit);
    }
    else
    {
        eMethodVal = resAreaOrHeight / this->yMinUnit;
    }
    f0 = 0.0;
    f1 = 0.0;
    f2 = 0.0;
    f3 = 0.0;
    //    X = 0.0;
    memset((void *)&idt1408, 0, sizeof(idt1408));
    if (!this->fetchIDT_1408Ex(idtNo, &f0, &f1, &f2, &f3, &idt1408))
    {
        return 0.0;
    }
    if (idt1408.SegCalibMode == 1 && idt1408.SegCalibCount > 0 && eMethodVal < idt1408.SegCalibItems[0].x)
    {
        X = idt1408.SegCalibItems[0].a * eMethodVal + idt1408.SegCalibItems[0].b;
    }
    else
    {
        X = f1 * eMethodVal + f0 + f3 * eMethodVal * eMethodVal + f2 * eMethodVal * eMethodVal * eMethodVal;
    }
    if (eMethod == 4)
    {
        if (X == 0.0)
        {
            X = 0.0;
        }
        else
        {
            X = exp(X);
        }
    }
    else if (eMethod == 2 || eMethod == 5)
    {
        if (idtAreaOrHeight <= 0.0)
        {
            X = 0.0;
        }
        else
        {
            X = X * idtWeight;
        }
    }
    return X;
}

// sub_1000C329
int32_t CConcCaculator::fetchIDT_1408Ex(int32_t idtNo, double *f0, double *f1, double *f2, double *f3,
                                        TDLLIDTListItem_1408Ex *idt1408)
{
    int32_t result;
    int32_t factorType;
    TDLLIDTListItem *pIDT = (TDLLIDTListItem *)this->pIdtInfWrapper->head;

    result = false;
    *f0 = 0.0;
    *f1 = 0.0;
    *f2 = 0.0;
    *f3 = 0.0;
    if (idt1408)
    {
        memset((void *)idt1408, 0, 0x200u);
    }
    if (idtNo < 0)
    {
        if (this->tukpkFactor.type > 0)
        {
            if (this->tukpkFactor.type <= 1)
            {
                if (this->tukpkFactor.type == 1)
                {
                    *f0 = this->tukpkFactor.f0;
                    *f1 = this->tukpkFactor.f1;
                    *f2 = this->tukpkFactor.f2;
                    *f3 = this->tukpkFactor.f3;
                    result = true;
                }
            }
            else
            {
                factorType = this->tukpkFactor.type - 2;
                *f0 = pIDT[factorType].f0;
                *f1 = pIDT[factorType].f1;
                *f2 = pIDT[factorType].f2;
                *f3 = pIDT[factorType].f3;
                if (idt1408)
                {
                    memcpy((void *)idt1408, (const void *)&pIDT[factorType]._1408Ex, 0x200u);
                }
                result = true;
            }
        }
    }
    else
    {
        *f0 = pIDT[idtNo].f0;
        *f1 = pIDT[idtNo].f1;
        *f2 = pIDT[idtNo].f2;
        *f3 = pIDT[idtNo].f3;
        if (idt1408)
        {
            memcpy((void *)idt1408, (const void *)&pIDT[idtNo]._1408Ex, 0x200u);
        }
        result = true;
    }
    return result;
}

// sub_1000C892
int32_t CConcCaculator::setResInfoConcM2M5(TDLLMETRIC *metric)
{
    int32_t eMethod;
    int32_t result;
    int32_t baseArea;
    double amtMethodVal;
    double idtAreaOrHeight;
    int32_t num;
    int32_t i;
    int32_t stdNo;
    double idtWeight;
    double conc;
    int32_t idno;
    double factor;

    num = this->pResInfWrapper->getNum();
    if (metric->byCalib)
    {
        amtMethodVal = 1.0;
        factor = 1.0;
    }
    else
    {
        eMethod = this->pEParaWrapper->getEparamMethod();
        amtMethodVal = calcAmtMValue((TSTDAMTListItem *)metric, eMethod);
        factor = pow10_istdK(metric);
    }
    for (i = 0;; ++i)
    {
        result = i;
        if (i >= num)
        {
            break;
        }
        conc = 0.0;
        stdNo = 0;
        idno = this->pResInfWrapper->getIdno(i);
        if (idno <= 0)
        {
            if (this->tukpkFactor.type > 0)
            {
                stdNo = this->pIdtInfWrapper->getStdnoUsed(-1);
            }
        }
        else if (this->pIdtInfWrapper->isStdnoUsed(idno - 1))
        {
            stdNo = this->pIdtInfWrapper->getStdnoUsed(idno - 1);
            if (stdNo <= 0)
            {
                stdNo = this->pIdtInfWrapper->getStdnoUsed(-1);
            }
        }
        else if (this->pIdtInfWrapper->checkStdNo(idno - 1))
        {
            stdNo = idno;
        }
        if (stdNo > 0)
        {
            TDLLIDTListItem *pIDT = (TDLLIDTListItem *)this->pIdtInfWrapper->head;
            idtWeight = pIDT[stdNo - 1].weight;
            baseArea = this->pEParaWrapper->isBasedOnArea();
            idtAreaOrHeight = this->pResInfWrapper->getAreaOrHeightByIdno(baseArea, stdNo);
            // double xx=this->calcAir( i, idtAreaOrHeight, idtWeight );
            // conc = idtAreaOrHeight * factor / amtMethodVal;
            conc = this->calcAir(i, idtAreaOrHeight, idtWeight);
        }
        this->pResInfWrapper->setConc(i, conc);
    }
    return result;
}

// sub_1000BA78
int32_t CConcCaculator::setBandOutConc(int32_t n, double factor, double mValue)
{
    double areaOrHeight;
    int32_t j;
    int32_t stdNo;
    double sumAreaOrHeight;
    int32_t basedOnArea;
    int32_t count;
    int32_t lastResIdx;
    int32_t i;
    double weight;
    int32_t eMethod;
    double X;

    if (n < 0 || n >= this->pIdtInfWrapper->getNum())
    {
        return false;
    }
    areaOrHeight = 0.0;
    weight = 0.0;
    eMethod = this->pEParaWrapper->getEparamMethod();
    if (eMethod == 2 || eMethod == 5)
    {
        stdNo = this->pIdtInfWrapper->getStdnoUsed(n);
        if (stdNo > 0)
        {
            TDLLIDTListItem *pIDT = (TDLLIDTListItem *)this->pIdtInfWrapper->head;
            weight = pIDT[stdNo - 1].weight;
            basedOnArea = this->pEParaWrapper->isBasedOnArea();
            areaOrHeight = this->pResInfWrapper->getAreaOrHeightByIdno(basedOnArea, stdNo);
        }
    }
    sumAreaOrHeight = 0.0;
    lastResIdx = -1;
    count = -1;
    for (i = 0; i < this->pResInfWrapper->getNum(); ++i)
    {
        if (this->pResInfWrapper->getIdno(i) == n + 1)
        {
            lastResIdx = i;
            do
            {
                basedOnArea = this->isIdtBaseOnArea(i);
                sumAreaOrHeight = this->pResInfWrapper->getAreaOrHeight(basedOnArea, i) + sumAreaOrHeight;
                count = i++;
            } while (this->pResInfWrapper->getIdno(i) == n + 1);
            break;
        }
    }
    X = this->calcIdtMethodVX(n, sumAreaOrHeight, areaOrHeight, weight);
    switch (eMethod)
    {
    case 2:
    case 5:
        X = mValue / factor * X;
        break;
    case 3:
    case 4:
    case 6:
        X = X / factor;
        break;
    default:
        break;
    }
    if (lastResIdx >= 0 && sumAreaOrHeight > 0.0)
    {
        for (j = lastResIdx; j <= count; ++j)
        {
            basedOnArea = this->isIdtBaseOnArea(j);
            areaOrHeight = this->pResInfWrapper->getAreaOrHeight(basedOnArea, j);
            double vv = areaOrHeight / sumAreaOrHeight * X;
            this->pResInfWrapper->setConc(j, vv);
        }
    }
    return true;
}

// sub_1001D8F0
int32_t CConcCaculator::setIdtTimeOfs(float fTimeOfs)
{
    if (!this->pIdtInfWrapper)
    {
        return false;
    }
    this->pIdtInfWrapper->timeOfs = fTimeOfs;
    return true;
}

// sub_1001D9D0
int32_t CConcCaculator::setIdtQualitMode(int32_t nQualitMode, float fTimeWindow)
{
    if (!this->pIdtInfWrapper)
    {
        return false;
    }
    this->pIdtInfWrapper->qualitMode = nQualitMode;
    if (nQualitMode != 1)
    {
        fTimeWindow = 0.0;
    }
    this->pIdtInfWrapper->timeWindow = fTimeWindow;
    return true;
}

// sub_1001DB80
int32_t CConcCaculator::setMiscellaneous(TMiscellaneous *wParam, int32_t byCalib)
{
    if (wParam)
    {
        memcpy((void *)&this->tukpkFactor, (void *)&wParam->UkPkFactor, sizeof(TUkPkFactor));
        this->yMinUnit = wParam->YMinUnit; //// 18,19 is error,should be 17,18
    }
    else
    {
        memset((void *)&this->tukpkFactor, 0, sizeof(TUkPkFactor));
        this->yMinUnit = 1.0;
    }
    if (this->pIdtInfWrapper)
    {
        this->pIdtInfWrapper->setMiscellaneous(wParam, byCalib);
    }
    if (this->pResInfWrapper)
    {
        this->pResInfWrapper->setXMinUnitK(wParam);
    }
    return true;
}
